package cn.schoolwow.ams.module.initial.flow;

import cn.schoolwow.ams.domain.block.router.RouterBlockBuilder;
import cn.schoolwow.ams.domain.option.QuickAMSListener;
import cn.schoolwow.ams.module.initial.domain.InitialAMSContext;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.util.List;

public class GetAMSRouterMenuArrayFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        InitialAMSContext initialAMSContext = flowContext.checkInstanceData(InitialAMSContext.class);
        List<QuickAMSListener> quickAMSListenerList = (List<QuickAMSListener>) flowContext.checkData("quickAMSListenerList");

        RouterBlockBuilder routerBlockBuilder = RouterBlockBuilder.newInstance();
        for(QuickAMSListener quickAMSListener:quickAMSListenerList){
            quickAMSListener.addRouterBlockArray(routerBlockBuilder);
        }
        initialAMSContext.routerArray = routerBlockBuilder.build();
    }

    @Override
    public String name() {
        return "获取AMS菜单列表";
    }
}
